import Mock from 'mockjs';
//import assetsJson from '../../data/media/assets.json';
import assetsJson from '../../data/media2/assets.json';
// import assetsJson from '../../data/audit/subAssets.json';


export default {
    className: "Media.Model.AssetsManage",
    queryData: function(postData) {
        
        return {
            isSuccess: "Y",
            reason: "",
            message: [],
            data: {
                recordCount: assetsJson.length,
                pageCount: 1,
                pageIndex: 1,
                pageSize: 20,
                queryResult: assetsJson
            }
        };

    },
    queryByKeyID: function(postData) {
      console.log(postData);
      var curFindObject = null;
      for (var i = 0; i < assetsJson.length; i++) {
          if (postData.keyID == assetsJson[i].keyID) {
              curFindObject = assetsJson[i];
              break;
          }
      }
      if (curFindObject == null) {
          return Mock.mock({
              isSuccess: "Y",
              reason: "",
              message: [],
              "data": {
              "keyID|1000-9999": 1000,
              "assetCode": /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/,
              "assetName": Mock.mock('@ctitle'),
              "subAssetCode": /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/, //@title为英文版
              "subAssetName": Mock.mock('@ctitle'),//标识符
              "genre": "正片",
              "episode|1000-9999": 1000,
              "sharpness": "SD",
              "status": "审核通过",
              "isStatus": "AuditPass",
              "absoluteAddress": "https://www.baidu.com/",
              "updateTime": Mock.mock('@now'),
              "creationTime": Mock.mock('@now'),
              "version": 1
            }
            });
          } else {
              return {
                  isSuccess: "Y",
                  reason: "",
                  message: [],
                  data: curFindObject,
              };
          }
      },
  };
